/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.colegiatura.bc;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.cip.esymons.colegiatura.be.VinculoColegiado;

/**
 *
 * @author ADMINISTRADOR
 */
@Stateless
public class VinculoColegiadoFacade implements VinculoColegiadoFacadeLocal {
    @PersistenceContext
    private EntityManager em;

    public void create(VinculoColegiado vinculoColegiado) {
        em.persist(vinculoColegiado);
    }

    public void edit(VinculoColegiado vinculoColegiado) {
        em.merge(vinculoColegiado);
    }

    public void remove(VinculoColegiado vinculoColegiado) {
        em.remove(em.merge(vinculoColegiado));
    }

    public VinculoColegiado find(Object id) {
        return em.find(VinculoColegiado.class, id);
    }

    public List<VinculoColegiado> findAll() {
        return em.createQuery("select object(o) from VinculoColegiado as o").getResultList();
    }

    public List<VinculoColegiado> listaVinculos(Long codigo) {
        return em.createQuery("select object(o) from VinculoColegiado as o where o.colCodigo.solCodigo=?1").setParameter(1, codigo).getResultList();
    }

}
